package com.bitin.adorn.modules.user.service.impl;

import com.bitin.adorn.common.payload.Pagination;
import com.bitin.adorn.modules.user.domain.User;
import com.bitin.adorn.modules.user.repository.UserRepository;
import com.bitin.adorn.modules.user.request.PagingRequest;
import com.bitin.adorn.modules.user.response.UserAuthInfo;
import com.bitin.adorn.modules.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户业务实现类
 *
 * @author Mr.Lu
 * @since 2024/12/17 16:58
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
    private final UserRepository userRepository;

    @Override
    public List<User> findAll(){
        return this.userRepository.findAll();
    }

    @Override
    public Pagination<User> page(PagingRequest request){
        Page<User> users = this.userRepository.findAll(request.convert());
        return Pagination.paging(users);
    }

    @Override
    @Transactional
    public User save(User user){
        return this.userRepository.save(user);
    }

    /**
     * 根据用户名获取认证信息
     *
     * @param username 用户名
     * @return {@link UserAuthInfo}
     */
    @Override
    public UserAuthInfo findUserAuthInfo(String username) {
        return null;
    }

    /**
     * 根据 openid 获取用户认证信息
     *
     * @param openid 微信
     * @return {@link UserAuthInfo}
     */
    @Override
    public UserAuthInfo findUserAuthInfoByOpenid(String openid) {
        return null;
    }

    @Override
    public void registerWechatUser(String openId) {

    }
}
